<template>
  <div class="">
    <input type="text" v-model="tit" @keydown.enter="search" />

    <ul>
      <li v-for="(item, index) in list" :key="index">
        {{ item.xh }}===={{ item.title }}==={{ item.sj }}
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [
        { xh: 1, title: "玛莎拉蒂", sj: new Date().toLocaleString() },
        { xh: 2, title: "特斯拉", sj: new Date().toLocaleString() },
        { xh: 3, title: "劳斯莱斯", sj: new Date().toLocaleString() },
        { xh: 4, title: "保时捷", sj: new Date().toLocaleString() },
      ],
      tit: "",
      copylist: [],
    };
  },
  mounted() {
    this.copylist = this.list;
  },
  methods: {
    search() {
      this.list = this.copylist.filter((item) => {
        return item.title.includes(this.tit);
      });
    },
  },
  components: {},
};
</script>

<style lang="scss"></style>
